package com.cqupt.interrgation.cquptinterrgation.mapper;

import com.cqupt.interrgation.cquptinterrgation.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper//这个Mapper加入将bean注入于springboot里
public interface Usermapper {//User表的查询接口
    @Select("SELECT * FROM user")
    List<User> findAll();
    @Select("SELECT nickname FROM user")
    List<User> findname();

    @Insert("INSERT INTO user(username,password,nickname,email,phone,address) VALUES(#{username},#{password},#{nickname},#{email},#{phone},#{address})")//#{}将静态数据改为动态数据
    int insert(User user);

    @Update("UPDATE user set username=#{username},password=#{password},nickname=#{nickname},email=#{email},phone=#{phone},address=#{address} where id=#{id}")
    int update(User user);
}
